/*
* Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class DefaultNodeCode {
    static nodeCode = {
        "ros1": `\
import rospy
from std_msgs.msg import UInt16, String

rospy.init_node('maestro_node')

def on_subscribe(msg, args):
    if args["type"] == "/topic1":
        print("Received message on topic1: ", msg.data)
        ret = String()
        ret.data = "data is "+str(msg.data)
        pub1.publish(ret)

pub1 = rospy.Publisher("/topic2", String, queue_size=10)

sub1 = rospy.Subscriber("/topic1", UInt16, on_subscribe, callback_args={"type":"/topic1"})

rospy.spin()
`,
        "ros2": `\
import rclpy
from std_msgs.msg import UInt16, String
`
    }
    static getNodeCode(type) {
        if (type in DefaultNodeCode.nodeCode) {
            return DefaultNodeCode.nodeCode[type];
        }
        return "";
    }
}

module.exports = {
    DefaultNodeCode,
}